<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateEatEveryDayTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $prefix = \Config::get('database.connections.mysql.prefix');
        $sql = <<<SQL
        create table {$prefix}eat_every_day
        (
          id int(10) unsigned not null auto_increment
            primary key,
          show_title varchar(200) not null comment '显示的标题',
          img_url varchar(255) not null comment '图片地址',
          name varchar(200) not null comment '商品名称',
          producing_area varchar(200) not null comment '产地',
          unit varchar(50) not null comment '规矩,一箱(6个装)!一件!或是一个',
          stock_num int default '0' null,
          status tinyint(1) default '0' null comment '1:上架 , 0:下架',
          on_off_time datetime default CURRENT_TIMESTAMP null comment '上架或下架的时间',
          created_at timestamp default CURRENT_TIMESTAMP not null,
          updated_at timestamp null default null,
          deleted_at timestamp null  default null
        );
SQL;
        if (!DB::statement($sql)) {
            throw new \Exception("failed on execute SQL: [{$sql}]");
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        throw new \Exception('downgrade is forbidden');
    }
}
